package com.zsrt.java.day20161230.lh.day.demo03;

/**
 * 一个类如果没有调用它的构造方法 null
 * @author My
 *
 */
public class Student {
	
	private String name;
	private String idNum;
	private char sex;
	private int age;
	private String schoolName;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		
		//一个类如果没有new 它为null
		if(null !=name){
			int len=name.length();
			if(len<=4 || len>=2){
				this.name = name;
			}else{
				System.out.println("名字长度不超过4个字");
			}
		}
	}
	public String getIdNum() {
		return idNum;
	}
	public void setIdNum(String idNum) {
		int len=name.length();
		if(18==len){
			this.idNum = idNum;
		}else{
			System.out.println("身份证长度为18个字");
		}
	}
	public char getSex() {
		return sex;
	}
	public void setSex(char sex) {
		if('男'==sex || '女'==sex){
			this.sex = sex;
		}else{
			System.out.println("性别为男或者女");
		}
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		if(age>=1 || age<=130){
			this.age = age;
		}else{
			System.out.println("年龄为1到130岁");
		}
	}
	public String getSchoolName() {
		return schoolName;
	}
	public void setSchoolName(String schoolName) {
		this.schoolName = schoolName;
	}
	@Override
	public String toString() {
		return "Student [name=" + name + ", idNum=" + idNum + ", sex=" + sex + ", age=" + age + ", schoolName="
				+ schoolName + "]";
	}
	

}
